/**
 * 文件操作
 */
use std::{fs::File, io::{Read, Write}};

pub fn run() {
    let file = File::open("./words.txt");
    println!("{:?}", file);

    let mut f_handler = File::create("./words.txt").expect("Failed to create");
    println!("f_handler {:?}", f_handler);
    let _ =  f_handler.write("welcome to learn rust\n".as_bytes());
    let _ = f_handler.write("welcome to learn webaseembly\n".as_bytes());
}

pub fn read_file() {
    let mut file = File::open("./words.txt").unwrap();
    println!("{:?}", file);
    let mut content = String::new();
    file.read_to_string(&mut content).unwrap();
    println!("content: {}", content);
}